package edu.tongji.libraryapp;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

public class BookDetailActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_book_detail);

		bindBackspaceFunction();
	}

	private void bindBackspaceFunction() {
		TextView bookDetailTitle = (TextView) findViewById(R.id.bookDetailTitleText);
		bookDetailTitle.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				Intent mainIntent = new Intent();
				mainIntent
						.setClass(BookDetailActivity.this, MainActivity.class);
				startActivity(mainIntent);
				overridePendingTransition(R.anim.slide_in_right,
						R.anim.slide_out_right);
			}
		});
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			Intent mainIntent = new Intent();
			mainIntent.setClass(BookDetailActivity.this, MainActivity.class);
			startActivity(mainIntent);
			overridePendingTransition(R.anim.slide_in_right,
					R.anim.slide_out_right);
		}
		return true;
	}
}
